



import java.util.*;

public class App {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        //存储员工信息的集合
        List<Map<String, Object>> em = new ArrayList<>();
        while (true) {
            System.out.println("请输入指令");
            // insert into Employee value("1","zs","24","asd","2500.00","2000-10-10");
            System.out.println("(insert-录入员工信息)");
            // select * from Employee where id = 1;
            System.out.println("(select-查询员工信息)");
            // update Employee set salary = 3000 where id = 1;
            System.out.println("(modify-修改员工信息)");
            // delete from Employee where id = 1;
            System.out.println("(remove-删除员工信息)");
            System.out.println("(result-完成员工表操作,查看结果)");
            System.out.println("(exit-退出程序)");
            String instruction = scanner.nextLine();
            String[] s = instruction.split(" ");
            if ("insert".equals(instruction)) {
                Add.add(em, instruction);
            } else if ("select".equals(instruction)) {
                Search.search(em, instruction);
            } else if ("modify".equals(instruction)) {
                Modify.modify(em, instruction);
            } else if ("remove".equals(instruction)) {
                Remove.remove(em, instruction);
            } else if ("result".equals(instruction)) {
                System.out.println("------查询结果------");
                System.out.println("员工总人数为:" + em.size());
                System.out.println("-------------------");
                System.out.println("员工平均薪资为为:" + Average.average(em));
                System.out.println("-------------------");
                System.out.println("年龄最大的员工信息为:");
                MaxAge.age(em);
                System.out.println("-------------------");
                System.out.println("年龄最小的员工信息为：");
                MinAge.age(em);
                System.out.println("-------------------");
                System.out.println("职位及其对应的员工数量:");
                JobAver.jobAver(em);
                System.out.println("-------------------");
                System.out.println("各个职位的平均薪资:");
                Set<Map.Entry<String, Double>> entries = SalaryAver.salaryAver(em).entrySet();
                for (Map.Entry<String, Double> entry : entries) {
                    System.out.println(entry);
                }
                System.out.println("-------------------");
            } else if ("exit".equals(instruction)) {
                System.exit(0);
            } else {
                System.out.println("输入有误，请重新输入");
            }
        }
    }
}
